package com.songlanyun.modules.integralconfig.controller.admin;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.annotation.RepeatSubmit;
import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.modules.integralconfig.entity.IntegralConfig;
import com.songlanyun.modules.integralconfig.service.IntegralConfigService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;


/**
 * 平台积分配置表
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-02-25 15:33:55
 */
@RestController
@RequestMapping("admin/integral/config")
public class IntegralConfigAdminController {
    @Autowired
    private IntegralConfigService integralConfigService;


    /**
     * 积分配置
     */
    @GetMapping("/info")
    //@RequiresPermissions("integralconfig:integralconfig:info")
    public R info() {
        IntegralConfig integralConfig = integralConfigService.get();
        return R.ok().put("data", integralConfig);
    }

    /**
     * 保存积分配置
     */
    @SysLog("保存积分配置")
    @RepeatSubmit("2")
    @PostMapping("/save")
    //@RequiresPermissions("integralconfig:integralconfig:save")
    public R save(@RequestBody IntegralConfig integralConfig) {
        ValidatorUtils.validateEntity(integralConfig);
        integralConfigService.saveIntegralConfig(integralConfig);
        return R.ok();
    }


}
